// 创建vuex对象
const obj = {

	state: {

		// 个人信息
		userinfo: {
			avatar: '/static/no.png',
			nickname: '未登录',
			mobile: '未绑定',
			money: 0.00,
		},

		// 系统配置
		system: uni.getStorageSync("system") ?? {},

		// 收款弹窗信息
		popupinfo: {},

		// 购物车
		cartList: [],

	},

	mutations: {

		// 设置用户信息
		setUserinfo(state, value) {
			uni.setStorageSync("userinfo", value);
			state.userinfo = value;
		},

		// 设置系统配置
		setSystem(state, value) {
			state.system = value;
			uni.setStorageSync("system", state.system);
		},

	},

	// 获取器
	getters: {

		userinfo(state) {
			return state.userinfo;
		},


		system(state) {
			return state.system;
		},

	},


	actions: {}
}


// #ifndef VUE3

import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store(obj);

// #endif


// #ifdef VUE3

import {
	createStore
} from 'vuex';
const store = createStore(obj);

// #endif

export default store;